package com.practice.controller.admin;

import com.practice.common.result.Result;
import com.practice.pojo.admin.dto.AdminRoleDTO;
import com.practice.pojo.admin.dto.AdminRolePageDTO;
import com.practice.pojo.admin.entity.Menu;
import com.practice.pojo.admin.entity.Role;
import com.practice.pojo.admin.vo.AdminRoleVO;
import com.practice.pojo.admin.dto.RoleDTO;
import com.practice.service.admin.AdminRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/sys_role")
public class AdminRoleController {

    @Autowired
    private AdminRoleService adminRoleService;

    @GetMapping("/list")
    public Result list(AdminRolePageDTO dto){
        return adminRoleService.page(dto);
    }

    @GetMapping("/rowInfo")
    private Result rowInfo(String id){
        return adminRoleService.rowInfo(id);
    }

    @PostMapping("/update")
    private Result update(@RequestBody RoleDTO dto){
        adminRoleService.update(dto);
        return Result.success();
    }

    @GetMapping("/allData")
    public Result allData(){
        return adminRoleService.allData();
    }
//    @GetMapping("/allData")
//    public Result allData(){
//        adminRoleService.allData();
//        return Result.success();
//    }

    //success
    @GetMapping("/del")
    public Result delete(String id){
        adminRoleService.delete(id);
        return Result.success();
    }

    //数据加进去会弹窗错误
    @PostMapping("/add")
    public Result add(@RequestBody AdminRoleDTO adminRoleDTO){
//        adminRoleService.add(adminRoleDTO);
        return adminRoleService.add(adminRoleDTO);
    }
}
